<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1" charset="UTF-8">
    <title>cleanup</title>
    <link href="../../images/logo-icon.svg" rel="icon" type="image/svg">
    <script>var pathToRoot = "../../";</script>
    <script>const storage = localStorage.getItem("dokka-dark-mode")
const savedDarkMode = storage ? JSON.parse(storage) : false
if(savedDarkMode === true){
    document.getElementsByTagName("html")[0].classList.add("theme-dark")
}</script>
<script type="text/javascript" src="../../scripts/sourceset_dependencies.js" async="async"></script>
<link href="../../styles/style.css" rel="Stylesheet">
<link href="../../styles/jetbrains-mono.css" rel="Stylesheet">
<link href="../../styles/main.css" rel="Stylesheet">
<link href="../../styles/prism.css" rel="Stylesheet">
<link href="../../styles/logo-styles.css" rel="Stylesheet">
<script type="text/javascript" src="../../scripts/clipboard.js" async="async"></script>
<script type="text/javascript" src="../../scripts/navigation-loader.js" async="async"></script>
<script type="text/javascript" src="../../scripts/platform-content-handler.js" async="async"></script>
<script type="text/javascript" src="../../scripts/main.js" defer="defer"></script>
<script type="text/javascript" src="../../scripts/prism.js" async="async"></script>
</head>
<body>
<div class="navigation-wrapper" id="navigation-wrapper">
    <div id="leftToggler"><span class="icon-toggler"></span></div>
    <div class="library-name">
            <a href="../../index.html">
                    <span>TeamCity Kotlin DSL</span>
            </a>
    </div>
    <div>
    </div>
    <div class="pull-right d-flex">
        <button id="theme-toggle-button"><span id="theme-toggle"></span></button>
        <div id="searchBar"></div>
    </div>
</div>
<div id="container">
    <div id="leftColumn">
        <div id="sideMenu"></div>
    </div>
    <div id="main">
<div class="main-content" id="content" pageIds="TeamCity Kotlin DSL::jetbrains.buildServer.configs.kotlin/BuildTypeSettings/cleanup/#kotlin.Function1[jetbrains.buildServer.configs.kotlin.Cleanup,kotlin.Unit]/PointingToDeclaration//1411724783">
  <div class="breadcrumbs"><a href="../../index.html">TeamCity Kotlin DSL</a><span class="delimiter">/</span><a href="../index.html">jetbrains.buildServer.configs.kotlin</a><span class="delimiter">/</span><a href="index.html">BuildTypeSettings</a><span class="delimiter">/</span><a href="cleanup.html">cleanup</a></div>
  <div class="cover ">
    <h1 class="cover"><span><span>cleanup</span></span></h1>
  </div>
  <div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-depenent-content" data-active="" data-togglable=":dokkaHtml/main"><div class="symbol monospace"><span class="token keyword"></span><span class="token keyword">fun </span><a href="cleanup.html"><span class="token function">cleanup</span></a><span class="token punctuation">(</span><span class="parameters "><span class="parameter ">init<span class="token operator">: </span><span class="token keyword"></span><a href="../cleanup/index.html">Cleanup</a><span class="token punctuation">.</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator"> -&gt; </span><span class="token keyword"></span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a></span></span><span class="token punctuation">)</span><span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div><p class="paragraph">Configures build <a href="https://www.jetbrains.com/help/teamcity/?Clean-Up#Clean-Up-ProjectClean-upRules">clean-up rules</a></p><p class="paragraph"><strong>Example.</strong> Keep all builds finished within 5 days after the last build</p><div class="sample-container"><pre><code class="block lang-kotlin" theme="idea">cleanup {<br>    keepRule {<br>        id = &quot;MyCleanupRule&quot;<br>        keepAtLeast = days(5) {<br>            since = lastBuild()<br>        }<br>        dataToKeep = everything()<br>        applyPerEachBranch = true<br>        preserveArtifactsDependencies = true<br>    }<br>}</code></pre><span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div><p class="paragraph">This cleanup rule tells TeamCity to keep all the builds which were fiished within 5 days since the last build.</p><p class="paragraph">The builds are kept per each branch individually.</p><p class="paragraph"><strong>Example.</strong> Keep not more than 10 personal builds</p><div class="sample-container"><pre><code class="block lang-kotlin" theme="idea">cleanup {<br>    keepRule {<br>        id = &quot;Keep10PersonalBuilds&quot;<br>        keepAtLeast = builds(10)<br>        applyToBuilds {<br>            inPersonalBuilds = onlyPersonal()<br>        }<br>        dataToKeep = everything()<br>        preserveArtifactsDependencies = true<br>    }<br>}</code></pre><span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div><p class="paragraph">Note: this should not be the only cleanup rule in the project, otherwise all other non-personal builds will be removed.</p><p class="paragraph"><strong>Example.</strong> Keep per-build statistics data for every build produced within 365 days since the last build</p><div class="sample-container"><pre><code class="block lang-kotlin" theme="idea">cleanup {<br>    keepRule {<br>        id = &quot;KeepStatisticsFor1Year&quot;<br>        keepAtLeast = days(365) {<br>          since = lastBuild()<br>        }<br>        dataToKeep = statisticsOnly()<br>    }<br>}</code></pre><span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div><p class="paragraph">Note: dataToKeep = statisticsOnly() means that only <a href="https://www.jetbrains.com/help/teamcity/custom-chart.html#Default+Statistics+Values+Provided+by+TeamCity">statistic values</a> will be preserved for the builds, everything else, like build logs, artifacts and the build itself will be removed. Preserved statistics values still allow to show data on the <a href="https://www.jetbrains.com/help/teamcity/custom-chart.html">custom charts</a> for such builds.</p><p class="paragraph"><strong>Example.</strong> Sets custom <a href="https://www.jetbrains.com/help/teamcity/?Clean-Up#Base+Rule">base cleanup rules</a> options.</p><div class="sample-container"><pre><code class="block lang-kotlin" theme="idea">cleanup {<br>    baseRule {<br>        history(builds = 3, days = 5)<br>        artifacts(builds = 3, days = 5, artifactPatterns = &quot;+:log*&quot;)<br>        preventDependencyCleanup = true<br>    }<br>}</code></pre><span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div><h2 class="">Parameters</h2><div data-togglable="Parameters"><div class="table" data-togglable="Parameters"><div class="table-row" data-filterable-current=":dokkaHtml/main" data-filterable-set=":dokkaHtml/main"><div class="main-subrow keyValue WithExtraAttributes"><div class=""><span class="inline-flex"><div><span><span>init</span></span></div></span></div><div><div class="title"><div data-togglable="Parameters"><p class="paragraph">function to initialize clean-up rules</p></div></div></div></div></div></div></div></div></div>
</div>
        <div class="footer"><span class="go-to-top-icon"><a href="#content" id="go-to-top-link"></a></span><span>© 2023 Copyright</span><span
                class="pull-right"><span>Generated by </span><a
                href="https://github.com/Kotlin/dokka"><span>dokka</span><span class="padded-icon"></span></a></span>
        </div>
    </div>
</div>
</body>
</html>
